import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: {},
    input: ''
  },
  mutations: {
    SAVE_LOGIN(state,user) {
      state.user = user
      // console.log(user)
      if(state.user) {
        localStorage.setItem('user',JSON.stringify(user))
      }
      // console.log("zhixing")
    }
  },
  actions: {
    saveLogin(context,user) {
      context.commit('SAVE_LOGIN',{ username:user.username,id: user.id })
    }
  },
  modules: {
  }
})
